<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var name=localStorage.getItem('name')
        // JSON.parse()可以接收的参数：数值，'1';布尔类型,'true','false';'null','[]','{}'
        var age=JSON.parse(localStorage.getItem('age'))
        var ismarry=JSON.parse(localStorage.getItem('ismarry'))
        var hobby=JSON.parse(localStorage.getItem('hobby'||'[]'))
        var dog=JSON.parse(localStorage.getItem('dog')||'{}')

        console.log(name,typeof name);
        console.log(age,typeof age);
        console.log(ismarry,typeof ismarry);
        console.log(hobby[0],typeof hobby);
        console.log(dog.name,typeof dog);
        
    </script>
</body>
</html>